---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: cluster-apps
  namespace: flux-system
spec:
  interval: 30m
  path: ./kubernetes/apps
  prune: true
  sourceRef:
    kind: GitRepository
    name: home-kubernetes
  decryption:
    provider: sops
    secretRef:
      name: sops-age
  postBuild:
    substituteFrom:
      - kind: ConfigMap
        name: cluster-settings
      - kind: Secret
        name: cluster-secrets
      - kind: ConfigMap
        name: cluster-user-settings
        optional: true
      - kind: Secret
        name: cluster-user-secrets
        optional: true
  patches:
    - patch: |-
        apiVersion: kustomize.toolkit.fluxcd.io/v1
        kind: Kustomization
        metadata:
          name: not-used
        spec:
          decryption:
            provider: sops
            secretRef:
              name: sops-age
          postBuild:
            substituteFrom:
              - kind: ConfigMap
                name: cluster-settings
              - kind: Secret
                name: cluster-secrets
              - kind: ConfigMap
                name: cluster-user-settings
                optional: true
              - kind: Secret
                name: cluster-user-secrets
                optional: true
      target:
        group: kustomize.toolkit.fluxcd.io
        kind: Kustomization
        labelSelector: substitution.flux.home.arpa/disabled notin (true)
